package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-04-20
 * Time: 14:30
 */
public class ThreadDemo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            //System.out.println("hello t!");
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        //在启动前 获取线程状态 NEW
        System.out.println(t.getState());

        t.start();

        Thread.sleep(1000);
        //在线程结束后 获取线程状态 TERMINATED
        //在线程在CPU上调度 RUNNABLE
        //使用sleep() TIMED_WAITING
        System.out.println(t.getState());

    }
}
